
<%--
    Document   : oEstrategico
    Created on : 10/04/2010, 03:05:56 PM
    Author     : LAPTOP01
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://struts.apache.org/tags-bean"  prefix="bean"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="/tags/c" prefix="c"%>
<%@ include file="seguridad.jsp" %>
<%@ include file="acceso.jsp" %>
<script src="scripts/ajax.js" language="JavaScript"></script>

<html>
    <script LANGUAGE="JavaScript">

         /*function actividades(codigo,desc){
            var form = document.getElementById("PEIForm");
            form.action="PEI.do?dispatch=listarMetaO&cod="+codigo+"&desc="+desc;
            form.method="post";
            form.submit();
        }*/

        function editar(cod,desc,techo){
            var form = document.getElementById("PEIForm");
            document.getElementById("opcion").value=2;
         
            document.getElementById("descDepen").value=desc;
          
            document.getElementById("techopDepen").value=techo;
            form.codDepen.value = cod;
            document.getElementById("edicion").style.display="";

        }

        function eliminar(codigo){
            var desc ="";
            var techo=0.0;

            var idDiv = "divTabla";
            var metodo = "GET";
            var tipo = 3;
            var url = "consultasAjax/listarPresupuestoAjax.jsp?techo="+techo+"&codigo="+codigo+"&tipo="+tipo+"&desc="+desc;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
          
        }
        function insertar(){
            var tipo=document.getElementById("opcion").value;
            var codigo = document.getElementById("codDepen").value;
            var techo = document.getElementById("techopDepen").value;
            var desc= document.getElementById("descDepen").value;
            var idDiv = "divTabla";
            var metodo = "GET";
            var url = "consultasAjax/listarPresupuestoAjax.jsp?techo="+techo+"&codigo="+codigo+"&tipo="+tipo+"&desc="+desc;
            var cadenaSalida = "";
       
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
            document.getElementById("opcion").value=1;
            document.getElementById("edicion").style.display="none";
          
        }

        function cancelar(){
            document.getElementById("edicion").style.display="none";
        }

        function listar(){
            var tipo=0;
            var codigo = document.getElementById("codDepen").value;
            var techo = document.getElementById("techopDepen").value;
            var desc= document.getElementById("descDepen").value;
            var idDiv = "divTabla";
            var metodo = "GET";
            var url = "consultasAjax/listarPresupuestoAjax.jsp?techo="+techo+"&codigo="+codigo+"&tipo="+tipo+"&desc="+desc;
            var cadenaSalida = "";

            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
            document.getElementById("opcion").value=1;
            document.getElementById("edicion").style.display="none";

        }


        function autoCompletarDiv(metodo,url,cadena,async,idDiv)
        {
            if( window.XMLHttpRequest )
                ajax = new XMLHttpRequest(); // No Internet Explorer
            else
                ajax = new ActiveXObject("Microsoft.XMLHTTP");
            ELEMENT_DIV = idDiv;
            ajax.onreadystatechange = funcionCallbackVerDiv;
            ajax.open( metodo, url, async);
            ajax.send(cadena);
        }

        function funcionCallbackVerDiv()
        {
            if( ajax.readyState == 4 )
            {
                if( ajax.status == 200 )
                { //alert(ajax.responseText);
                    document.getElementById(ELEMENT_DIV).innerHTML = ajax.responseText;
                }
            }
        }

        function posicioninicial(){
            document.getElementById("techopDepen").focus();
        }

    </script>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link type="text/css" rel="stylesheet" href="lib/css/Style_Index.css" >
        <link type="text/css" rel="stylesheet" href="lib/css/Style_Font_Text.css" >
        <link type="text/css" rel="stylesheet" href="lib/css/Style_PageTable.css" >
        <title>JSP Page</title>
    </head>
    <body onload="listar()">
        <center>
            <h1 class="substylo">Techo Presupuestal</h1>
        </center>
        <div style="overflow: auto; width:710px; height: 400px">
                        <html:form action="PEI.do?dispatch=ingresarOEstrategico" styleId="PEIForm">
                            <html:hidden property="opcion" styleId="opcion" value="1"/>
                            <html:hidden property="codDepen" styleId="codDepen"/>
                            <html:hidden property="descDepen" styleId="descDepen"/>
                            <table border="1" align="center" cellspacing="0" id="edicion">
                    <tr><td>
                            <html:text  styleId="techopDepen" property="techopDepen" maxlength="400" styleClass="text"/>
                                    </td>
                                </tr>
                                <tr><td align="center">
                                <input type="button" value="Grabar" onclick="insertar()" class="submit2"/>
                                <input type="button" value="Cancelar" onclick="cancelar()" class="submit2"/>
                                    </td>
                                </tr>
                            </table>
                             <div id="divTabla">

                             </div>

                        </html:form>
        </div>
</html>